<template>
  <el-dialog
    :title="view === 'detail'? '模块详情': ''"
    :visible="true"
    custom-class="orderDetailWrapper"
    :before-close="closeDialog"
    >
    <vue-body>
    	<el-form :model="tableData" label-width="120px">
    		<el-form-item label="机构编号">
        	<el-input v-model="tableData.institutionNo" auto-complete="off" readonly="readonly"></el-input>
      	</el-form-item>
      	<el-form-item v-if="bannerType == '01'|| bannerType == '03'" label="图片名称">
        	<el-input v-model="tableData.name" auto-complete="off" readonly="readonly"></el-input>
      	</el-form-item>
        <el-form-item v-if="bannerType == '00'" label="关联商品名称">
        	<el-input v-model="tableData.productName" auto-complete="off" readonly="readonly"></el-input>
      	</el-form-item>
        <el-form-item v-if="bannerType == '00'" label="关联商品编号">
        	<el-input v-model="tableData.productNo" auto-complete="off" readonly="readonly"></el-input>
      	</el-form-item>
        <el-form-item v-if="bannerType == '01'|| bannerType == '03'" label="banner跳转链接">
        	<el-input v-model="tableData.url" auto-complete="off" readonly="readonly"></el-input>
      	</el-form-item>
        <el-form-item label="排序">
        	<el-input v-model="tableData.seq" auto-complete="off" readonly="readonly"></el-input>
      	</el-form-item>
        <el-form-item v-if="bannerType == '01'|| bannerType == '03'" label="广告图片">
      		<div class="imgBox">
        	<!--<el-input v-model="tableData.industry" auto-complete="off" readonly="readonly"></el-input>-->
        	<img class="logoImg" :src="imgSrc(tableData.picUrl)"/>
        	</div>
      	</el-form-item>
    	</el-form>
    </vue-body>
    <div slot="footer" class="dialog-footer">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button type="info" @click="submit('ruleForm')">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { advertDetail} from "@/services/module";
import { RequestError } from "@/services/errors";
import { mapActions } from "vuex";
export default {
  name: "edit-role",
  data () {
    return {
      loading: false,
      formData: {
      },
      dialogFormVisible: false,
      tableData: {},
      id:"",
      bannerType:""
    }
  },
  props: {
    view: {
      type: String,
      default: "detail"
    }
  },
  methods: {
    ...mapActions(["setUserInfo"]),
    closeDialog() {
      this.$emit("close");
    },
    imgSrc(data){
      	return this.$store.state.imgUrl + data;
    },
    submit() {
    	this.$emit("close");
    },
    async loadData () {
        this.loading = true
        try {
          let data = await advertDetail({id:this.id,bannerType:this.bannerType})
          // debugger
					this.tableData = data.data
        } catch (e) {
          if (e instanceof RequestError) {
            this.$alert(e.message, '提示', {
              type: 'error',
              confirmButtonText: '确定'
            })
          } else {
            throw e
          }
        }
        this.loading = false
      },
  },
  mounted() {
  	
  },
  filters: {
      status (value) {
        return {'00': '禁用', '01': '启用', '02': '删除'}[value]
      },
      bannerType (value) {
        return {'00': '商品', '01': '图片广告','02':'轮播图'}[value]
      }
  },
};
</script>
<style>
.el-select {
  width: 100%;
}
.orderDetailWrapper{
  width: 50%;
}
.typeBox{
	background-color: #fff;
    background-image: none;
    border-radius: 4px;
    border: 1px solid #bfcbd9;
    box-sizing: border-box;
    color: #1f2d3d;
    font-size: inherit;
    height: 36px;
    line-height: 30px;
    outline: 0;
    padding: 3px 10px;
    transition: border-color .2s cubic-bezier(.645,.045,.355,1);
}
.logoImg{
	height: 120px;
	border-radius: 4px;
	border: 1px solid #bfcbd9;
	padding: 5px;
}
.el-textarea__inner{
	height: 100px;
	resize:none;
}
</style>
